package com.feng.show.service.impl;

import com.feng.show.comm.ServerResponse;
import com.feng.show.dao.UserInfoMapper;
import com.feng.show.entity.UserInfo;
import com.feng.show.entity.UserInfoExample;
import com.feng.show.service.IUserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;


@Service("IUserLoginService")
public class UerLoginServiceImpl implements IUserLoginService {

    @Autowired
    UserInfoMapper mapper;

    @Override
    public ServerResponse<UserInfo> doLogin(String uName, String pwd) {
        UserInfoExample userExample=new UserInfoExample();
        UserInfoExample.Criteria  criteria=userExample.createCriteria();

        criteria.andUserNameEqualTo(uName).andPasswdEqualTo(pwd);

        List<UserInfo> list=mapper.selectByExample(userExample);
        if(list!=null&&list.size()>0){
            UserInfo u=list.get(0);
            return ServerResponse.createBySuccesMsg(u);
        }else{
            return ServerResponse.createBySuccessMsg("用户名或者密码错误");
        }
    }

    //添加用户

}
